IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SrvrInstncDatabaseSize]') AND type in (N'U'))
BEGIN
     DROP TABLE [dbo].[SrvrInstncDatabaseSize]
END
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[SrvrInstncDatabaseSize](
     [SrvrInstncDatabaseId]   [int]      NOT NULL,
     [PackageExecutionId]     [bigint]   NOT NULL,
     [CaptureDt]              [datetime] NOT NULL,
     [CurrentRecordForDtFlag] [tinyint]  NOT NULL CONSTRAINT [DF_SrvrInstncDatabaseSize_CurrentRecordForDtFlag] DEFAULT ((0)),
     [TotalDataSpaceMB]       [int]      NOT NULL,
     [TotalDataFiles]         [int]      NOT NULL,
     [TotalLogSpaceMB]        [int]      NOT NULL,
     [TotalLogFiles]          [int]      NOT NULL,
     [CollectionDateOnly]  AS (dateadd(day,datediff(day,(0),[CaptureDt]),(0))) PERSISTED,
     CONSTRAINT [PK_SrvrInstncDatabaseSize] PRIMARY KEY CLUSTERED ( [SrvrInstncDatabaseId] ASC, [CaptureDt] ASC )
) ON [PRIMARY]
GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Date/time sample was collected.  Use CollectionDateOnly for reporting.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SrvrInstncDatabaseSize', @level2type=N'COLUMN',@level2name=N'CaptureDt'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Flag indicating that this record is the most current record for a specified collection date.  This field should be used for recporting on a specific date, records that are zero should be ignored.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SrvrInstncDatabaseSize', @level2type=N'COLUMN',@level2name=N'CurrentRecordForDtFlag'
GO
